<script>
import { onUpdated, toRefs, ref, h } from 'vue';

export default {
    props: {
        schoolName: {
            type: String,
            defalut: '你好呀！'
        }
    },
    setup(props, context) {
        const { schoolName } = toRefs(props)
        console.log(schoolName.value)
        onUpdated(() => {
            console.log(schoolName.value)
        })

        console.log(context);

        const num = ref(21)
        function sendParent() {
            context.emit('injectdata', num.value)
        }

        context.expose({
            sendParent,
            schoolName,
            num
        })
        return () => h('div', num.value)
    }

}
</script>

<template>
    <div>
        <h1>{{schoolName}}</h1>
        <button @click="sendParent">给父亲发送数据点我</button>
    </div>
</template>



<style lang="scss" scoped>

</style>